using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FrameOperateSync;
using System.IO;

public class AGameRender : MonoBehaviour
{
    private void Awake()
    {
        UnityEngine.Application.runInBackground = false;
        RenderUtility.RecordDataRecvdEvt += SaveRecordData;
    }

    private void FixedUpdate()
    {
        RenderUtility.GameFixedUpdaterRender();
    }

    private void OnDestroy()
    {
        RenderUtility.DisposeGame();
    }

    private void SaveRecordData(KeyFrameRecordData[] recordDatas)
    {
#if UNITY_EDITOR
        var p = new Pack<KeyFrameRecordData[]>();
        p.data = recordDatas;
        var json = JsonUtility.ToJson(p);
        FileInfo fi = new FileInfo(Path.Combine(Application.dataPath,"hh.txt"));
        var sw = fi.CreateText();
        sw.WriteLine(json);
        sw.Close();
        sw.Dispose();
#endif
    }
    
    [System.Serializable]
    public class Pack<T>
    {
        public T data;
    }
}